<?php
namespace Tbf\Bundle\AjkApiBundle\Controller;
use Tbf\Bundle\ShopFrontBundle\Annotations\HtmlMessage;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Translation\TranslatorInterface;
use Tbf\Bundle\TbfBundle\Controller\TbfController;
use Tbf\Bundle\TbfBundle\Exception\BusinessException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class HtmlMessageController extends TbfController{
    /** @var \Symfony\Component\Translation\TranslatorInterface  */
    protected $translator;
    /** @var \Symfony\Bundle\TwigBundle\TwigEngine  */
    protected $templating;
    function __construct(TranslatorInterface $translator,TwigEngine $templaing){
        $this->translator = $translator;
        $this->templating = $templaing;
    }
    /**
     * @param string|null $info
     * @return \Symfony\Component\HttpFoundation\Response
     */
    function errorPage($info=null,$option=array()){
        if ($info===null){
            $info = '操作执行失败';
        }
        $info = $this->translator->trans($info);
        $option['info'] = $info;
        return $this->templating->renderResponse('TbfAjkApiBundle:HtmlMessage:error.html.twig', $option);
    }

    /**
     * @param string|null $info
     * @return \Symfony\Component\HttpFoundation\Response
     */
    function successPage($info=null,$option=array()){
        if ($info===null){
            $info = '操作执行成功';
        }
        $info = $this->translator->trans($info);
        $option['info'] = $info;
        return $this->templating->renderResponse('TbfAjkApiBundle:HtmlMessage:success.html.twig', $option);
    }
}
